<?php

require_once 'model/contas.php';

abstract class ActContas extends mContas {
	
	protected $sqlInsert = "insert into contas (nome_conta) values ('%s')";
	protected $sqlDelete = "delete from contas where cod_conta = '%s'";
	protected $sqlUpdate = "update contas set nome_conta='%s' where cod_conta='%s'";
	protected $sqlSelect = "select * from contas %s %s";

	public function load(){
		$rs = $this->select(sprintf("where cod_conta = %s",$this->getCodConta()));
		$this->setCodConta($rs[0]['cod_conta']);
		$this->setNomeConta($rs[0]['nome_conta']);
		return $this;
	}
		
	
	public function insert(){
		$sql = sprintf($this->sqlInsert,
					   $this->getNomeConta()
					  );
		return $this->RunQuery($sql);
	}
	
	public function delete (){
		$sql = sprintf($this->sqlDelete,
					   $this->getCodConta()
					  );
		return $this->RunQuery($sql);
	}
	
	public function update(){
		$sql = sprintf($this->sqlUpdate,
					   $this->getNomeConta(),
					   $this->getCodConta()
					  );
		return $this->RunQuery($sql);					  
	}
	
	public function select($where = '', $oder=''){
		$sql = sprintf($this->sqlSelect,
						$where,
						$oder
					   );
		return $this->RunSelect($sql);			   
	}
}
?>